﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;

namespace MouseExtender.Logic.Helpers
{
	/// <summary>
	/// Helper for hiding controls when dialog opened
	/// <example>
	/// private void btnAddExcludedProgram_Click(object sender, RoutedEventArgs e)
	/// {
	///		using (ControlHide hideSettings = new ControlHide(this))
	///		{
	///			//show dialog and perform actions
	///		}
	/// }
	/// </example>
	/// </summary>
	public class ControlHide : IDisposable
	{
		private FrameworkElement _control = null;

		/// <summary>
		/// Initializes a new instance of the <see cref="ControlHide"/> class.
		/// </summary>
		/// <param name="control">The control to be hidden.</param>
		public ControlHide(FrameworkElement control)
		{
			_control = control;
			_control.Visibility = Visibility.Collapsed;
		}

		public void Dispose()
		{
			_control.Visibility = Visibility.Visible;
		}
	}
}
